package com.estate.framework.web.pojo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashMap;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = false)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ListingFilter {
    private String status;
    private String category;
    private String method;
    private String updatedDateFrom;
    private String updatedDateTo;
    private String lastModifiedFrom;
    private String lastModifiedTo;
    private String listedDateFrom;
    private String listedDateTo;
    private String enquiryDateFrom;
    private String enquiryDateTo;

    public Map<String, String> toMap() {
        Map<String, String> filters = new HashMap<>();
        if (status != null && !status.isEmpty()) {
            filters.put("status", status);
        }
        if (category != null && !category.isEmpty()) {
            filters.put("category", category);
        }
        if (method != null && !method.isEmpty()) {
            filters.put("method", method);
        }
        if (updatedDateFrom != null && !updatedDateFrom.isEmpty()) {
            filters.put("updated_date_from", updatedDateFrom);
        }
        if (updatedDateTo != null && !updatedDateTo.isEmpty()) {
            filters.put("updated_date_to", updatedDateTo);
        }
        if (listedDateFrom != null && !listedDateFrom.isEmpty()) {
            filters.put("listed_date_from", listedDateFrom);
        }
        if (listedDateTo != null && !listedDateTo.isEmpty()) {
            filters.put("listed_date_to", listedDateTo);
        }
        if (lastModifiedFrom != null && !lastModifiedFrom.isEmpty()) {
            filters.put("last_modified_from", lastModifiedFrom);
        }
        if (lastModifiedTo != null && !lastModifiedTo.isEmpty()) {
            filters.put("last_modified_to", lastModifiedTo);
        }
        if (enquiryDateFrom != null && !enquiryDateFrom.isEmpty()) {
            filters.put("enquiry_date_from", enquiryDateFrom);
        }
        if (enquiryDateTo != null && !enquiryDateTo.isEmpty()) {
            filters.put("enquiry_date_to", enquiryDateTo);
        }
        return filters;
    }
}
